<?php include $this->admin_tpl('meta','admin');?>
<title>留言管理 - YzmCMS内容管理系统</title>
</head>
<body>
<nav class="breadcrumb"><i class="yzm-iconfont yzm-iconai-home"></i> 首页 <span class="c-gray en">&gt;</span> 模块管理 <span class="c-gray en">&gt;</span> 留言管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="yzm-iconfont yzm-iconshuaxin"></i></a></nav>
<div class="page-container">
  <div> 
		<form action="<?php echo U('search');?>" method="get">
		 时间：<input type="text" class="input-text laydate-icon" style="width:170px;height:30px;" id="start" name="start" <?php if(isset($_GET['start']) && $_GET['start'] != '') echo 'value="'.$_GET['start'].'"'; ?>>
    	 至 <input type="text" class="input-text laydate-icon" style="width:170px;height:30px;" id="end" name="end" value="<?php if(isset($_GET['end']) &&  $_GET['end'] != '') echo $_GET['end']; else echo date('Y-m-d H:i:s'); ?>">				
		  <span class="select-box inline">
		 	<select name="ischeck" class="select">
		 		<option value="99">审核状态</option>
		 		<option <?php if(isset($_GET["ischeck"]) && $_GET["ischeck"]=='0'){echo "selected";} ?> value="0">未审核</option>
		 		<option <?php if(isset($_GET["ischeck"]) && $_GET["ischeck"]=='1'){echo "selected";} ?> value="1">已审核</option>
		 	</select>
		 </span>
		 <span class="select-box inline">
		 	<select name="isread" class="select">
		 		<option value="99">阅读状态</option>
		 		<option <?php if(isset($_GET["isread"]) && $_GET["isread"]=='0'){echo "selected";} ?> value="0">未读</option>
		 		<option <?php if(isset($_GET["isread"]) && $_GET["isread"]=='1'){echo "selected";} ?> value="1">已读</option>
		 	</select>
		 </span>
		 <span class="select-box inline">
			<select name="type" class="select">
				<option <?php if(isset($_GET["type"]) && $_GET["type"]=='1'){echo "selected";} ?> value="1">留言主题</option>
				<option <?php if(isset($_GET["type"]) && $_GET["type"]=='2'){echo "selected";} ?> value="2">联系人</option>		
			</select>
		</span>
		 <input type="text" name="searinfo"  class="input-text" style="width:170px" value="<?php if(isset($_GET['searinfo'])) echo $_GET['searinfo'];?>"><button name="dosubmit" class="btn btn-success" type="submit" value="1"><i class="yzm-iconfont yzm-iconsousuo"></i> 搜索</button>
		</form>	
  </div>

	<div class="cl mt-15 tb-top"> 
		<span class="l">
			<a href="javascript:;" onclick="yzm_dels('id', 1)" class="btn btn-danger radius"><i class="yzm-iconfont yzm-iconshanchu2"></i> 批量删除</a>
			<a href="javascript:;" onclick="set_read()" class="btn btn-success radius"><i class="yzm-iconfont yzm-iconyoujian"></i> 标识已读</a>
		</span>
	</div>
	<form method="post" action="<?php echo U('del');?>" id="myform">
	<table class="table table-border table-bg table-hover yzm-table-sort">
		<thead>
			<tr class="text-c">
				<th width="35"><input type="checkbox"></th>
				<th width="50">ID<?php echo field_order('id');?></th>
				<th style="text-align:left">留言主题</th>
				<th width="200" style="text-align:left">联系人</th>
				<th width="100">IP地址<?php echo field_order('ip');?></th>
				<th width="150">留言日期<?php echo field_order('booktime');?></th>
				<th width="70">状态<?php echo field_order('isread');?></th>
				<th width="70">审核<?php echo field_order('ischeck');?></th>	
			</tr>
		</thead>
		<tbody>
			<?php 
			   foreach($data as $val){
			 ?>
			<tr class="text-c">
				<td><input type="checkbox" value="<?php echo $val['id']?>" name="id[]"></td>
				<td><?php echo $val['id']?></td>
				<td style="text-align:left"><a href="javascript:;" onclick="yzm_open_full('查看留言','<?php echo U('read',array('id'=>$val['id']));?>')" ><?php echo $val['title'];?></a> <span class="yzmcms_small"><?php echo $val['ispc'] ? '<i class="yzm-iconfont yzm-icondiannao" title="来自PC端"></i>' : '<i class="yzm-iconfont yzm-icontel" title="来自移动端"></i>';?></span></td>
				<td style="text-align:left"><?php echo $val['name'];?></td>
				<td><?php echo $val['ip'];?></td>
				<td><?php echo date('Y-m-d H:i:s',$val['booktime']);?></td>
				<td><?php echo $val['isread'] ? '已读' : '<span class="c-red">未读</span>'; ?></td>
				<td>
					<?php if($val['ischeck']){ ?>
					<span class="yzm-status-enable" data-field="ischeck" data-id="<?php echo $val['id']?>" onclick="yzm_change_status(this,'<?php echo U('toggle');?>')"><i class="yzm-iconfont">&#xe81f;</i>是</span>
					<?php }else{ ?>
					<span class="yzm-status-disable" data-field="ischeck" data-id="<?php echo $val['id']?>" onclick="yzm_change_status(this,'<?php echo U('toggle');?>')"><i class="yzm-iconfont">&#xe601;</i>否</span>
					<?php } ?>
				</td>
			</tr>
			<?php 
			   }		 
			?>	
		</tbody>
	</table>
	<?php if(!$data){ ?><div class="yzm_no_data"><i class="yzm-iconfont yzm-iconshuoming"></i> 暂无数据</div><?php } ?>
	</form>
	<div id="page"><span class="page_left">共<?php echo $total?>条记录，共<?php echo $page->total()?>页，当前显示第<?php echo $page->getpage()?>页</span>
  <span class="page_right"><?php echo $page->getfull();?></span></div>
</div>
<?php include $this->admin_tpl('footer','admin');?>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/laydate/1.1/laydate.js"></script>
<script>
	var start = {elem:'#start',format:'YYYY-MM-DD hh:mm:ss',min:'1999-01-01',max:'2099-01-01',istime:true,istoday:false,choose:function(datas){end.min = datas;end.start = datas}
	};
	var end = {elem:'#end',format:'YYYY-MM-DD hh:mm:ss',min:'1999-01-01',max:'2099-01-01',istime:true,istoday:false,choose:function(datas){start.max = datas;}};
	laydate(start);
	laydate(end);

	function set_read() {
		if ($("input[name='id[]']:checked").length<1){
		   layer.alert('请勾选信息！');
		   return false;
		}	
		$.ajax({
			type: 'POST',
			url: '<?php echo U('set_read');?>', 
			data: $("#myform").serialize(),
			dataType: "json", 
			success: function (msg) {
				if(msg.status == 1){
					layer.msg(msg.message, {icon:1, time:1000}, function(){
						location.reload();
					});
			    }else{
					layer.msg(msg.message, {icon:2});
				}
			}
	    })
	}
</script>
</body>
</html>